//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
    gridBody: '',
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: { view: [], box: [], detail: [] },//扩展的按钮
  methods: {//事件扩展
    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    onInit () {
      this.boxOptions.labelWidth = 140
      this.boxOptions.width = 800
      this.boxOptions.height = 300
      let appointment_time = this.getFormOption('appointment_time');
      let starting_nine = this.getFormOption('starting_nine');
      let starting_ten = this.getFormOption('starting_ten');
      let starting_thirteen = this.getFormOption('starting_thirteen');
      let starting_eighteen = this.getFormOption('starting_eighteen');
      // appointment_time.data.forEach(i => {
      //   switch (i.key) {
      //     case 'starting_nine':
      //       this.editFormOptions[3][0] = { "title": i.value, "field": "starting_nine", "type": "number", hidden: true }
      //       break;
      //     case 'starting_ten':
      //       this.editFormOptions[3][1] = { "title": i.value, "field": "starting_ten", "type": "number", hidden: true }
      //       break;
      //     case 'starting_thirteen':
      //       this.editFormOptions[4][0] = { "title": i.value, "field": "starting_thirteen", "type": "number", hidden: true }
      //       break;
      //     case 'starting_eighteen':
      //       this.editFormOptions[3][1] = { "title": i.value, "field": "starting_eighteen", "type": "number", hidden: true }
      //       break;
      //   }
      // })
      // appointment_time.onChange = (v) => {
      //   starting_nine.hidden = true
      //   starting_ten.hidden = true
      //   starting_thirteen.hidden = true
      //   starting_eighteen.hidden = true
      //   if (v.length) {
      //     v.forEach(i => {
      //       switch (i) {
      //         case 'starting_nine':
      //           starting_nine.hidden = false
      //           break;
      //         case 'starting_ten':
      //           starting_ten.hidden = false
      //           break;
      //         case 'starting_thirteen':
      //           starting_thirteen.hidden = false
      //           break;
      //         case 'starting_eighteen':
      //           starting_eighteen.hidden = false
      //           break;
      //       }
      //     })
      //   }
      // }
    },
    modelOpenAfter (row) {
      // if (this.currentAction == "Add") { } else {
      //   let starting_nine = this.getFormOption('starting_nine');
      //   let starting_ten = this.getFormOption('starting_ten');
      //   let starting_thirteen = this.getFormOption('starting_thirteen');
      //   let starting_eighteen = this.getFormOption('starting_eighteen');
      //   starting_nine.hidden = true
      //   starting_ten.hidden = true
      //   starting_thirteen.hidden = true
      //   starting_eighteen.hidden = true
      //   if (row.appointment_time != null) {
      //     let appointment_time = row.appointment_time.split(',')
      //     appointment_time.forEach(i => {
      //       switch (i) {
      //         case 'starting_nine':
      //           starting_nine.hidden = false
      //           break;
      //         case 'starting_ten':
      //           starting_ten.hidden = false
      //           break;
      //         case 'starting_thirteen':
      //           starting_thirteen.hidden = false
      //           break;
      //         case 'starting_eighteen':
      //           starting_eighteen.hidden = false
      //           break;
      //       }
      //     })
      //   }
      // }
    },
    rowClick ({ row, column, event }) {
      //查询界面table点击行选中当前行
      this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    },
    updateBefore (formData) {
      // let obj = {
      //   starting_nine: '',
      //   starting_ten: '',
      //   starting_thirteen: '',
      //   starting_eighteen: '',
      // }
      // if (this.editFormFields.appointment_time.length) {
      //   for (const key in obj) {
      //     if (!this.editFormFields.appointment_time.includes(key)) {
      //       obj[key] = ''
      //     } else {
      //       obj[key] = this.editFormFields[key]
      //     }
      //   }

      // }
      // formData.mainData = {
      //   ...this.editFormFields,
      //   ...obj,
      // }
      // formData.mainData.appointment_time = this.editFormFields.appointment_time.join()
      return true
    },
  }
};
export default extension;
